'use strict';

var gulp = require('gulp');
var postcss = require('gulp-postcss');
var cssmin = require('gulp-cssmin');
var salad = require('postcss-salad')(require('./salad.config.json'));

function swallowError(error) {
	console.error(error.toString());
	this.emit('end');
}

gulp.task('compile', function() {
	return gulp.src('./src/*.css')
		.pipe(postcss([salad]))
		.on('error', swallowError)
		.pipe(cssmin())
		.pipe(gulp.dest('./dist'));
});

gulp.task('copyfont', function() {
	return gulp.src('./src/components/fonts/**')
		.pipe(gulp.dest('./dist/components/fonts'));
});

gulp.task('build', ['compile', 'copyfont']);

gulp.task('watch', function() {
	gulp.watch(['./src/**',], ['build']);
})